package urltest;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

public class Vc {
	public static void main(String[] args) throws Exception {
		URL url = new URL("http://1.85.55.152/sys/ValidateCode.aspx");
		HttpURLConnection con = (HttpURLConnection)url.openConnection();
		
		con.setRequestMethod("GET");
		con.setRequestProperty("Accept",  "image/webp,image/*,*/*;q=0.8");
		con.setDoInput(true);
		con.setDoOutput(true);
		
		BufferedInputStream in = new BufferedInputStream(con.getInputStream());
		BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream("checkCode2.jpg"));
		byte[] buffer = new byte[128];
		int len = 0;
		while ((len = in.read(buffer)) != -1) {
			out.write(buffer, 0, len);
		}
		in.close();
		out.close();
		con.connect();
	}
}
